package cn.edu.neusoft.wuguangsheng.market.activity;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import cn.edu.neusoft.wuguangsheng.market.R;
import cn.edu.neusoft.wuguangsheng.market.bean.RegisterBean;
import cn.edu.neusoft.wuguangsheng.market.listener.TListener;
import cn.edu.neusoft.wuguangsheng.market.model.InsertCommentModel;

public class InsertCommentActivity extends BaseActivity {
    String orid,fid,uid,mrid;
    EditText et_comment;
    Button btn_comment;
    ImageView comfl;
    @Override
    void initView() {

        setLayout_file(R.layout.activity_insert_comment);
        orid = getIntent().getStringExtra("orid");
        fid = getIntent().getStringExtra("fid");
       // mrid=getIntent().getStringExtra("mrid");
        mrid=getmrid();
        //Toast.makeText(InsertCommentActivity.this,mrid,Toast.LENGTH_SHORT).show();
        et_comment=(EditText)findViewById(R.id.et_comment);
        btn_comment=(Button)findViewById(R.id.btn_comment);
        comfl=(ImageView)findViewById(R.id.comfl);
        //Toast.makeText(InsertCommentActivity.this,mrid,Toast.LENGTH_SHORT).show();
    }

    @Override
    void initEvent() {
        btn_comment.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        String content=et_comment.getText().toString();
        if(content.equals("")){
            Toast.makeText(InsertCommentActivity.this,"评论内容不能为空",Toast.LENGTH_SHORT).show();
        }
        else{
            uid=getid();
            InsertCommentModel insertCommentModel=new InsertCommentModel();
            insertCommentModel.InsertComment(orid,content,fid,uid,mrid,tListener);
        }
    }
});
        comfl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    void initDate() {

    }
    TListener<RegisterBean> tListener=new TListener<RegisterBean>() {
        @Override
        public void onResponse(RegisterBean registerBean) {
           String success=registerBean.getSuccess();
            if(success.equals("1")){
                Toast.makeText(InsertCommentActivity.this,"评论成功",Toast.LENGTH_SHORT).show();
                finish();
            }
            else{
                Toast.makeText(InsertCommentActivity.this,"评论失败",Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onFail(String msg) {

        }
    };
}
